// 活动 贷款 信用卡 点击图片进入详情的统一处理
export default {
    name: 'mxProductImage',
    data() {
        return {};
    },
    mounted() {},
    methods: {
        // 点击当前图片
        mxHandleClick(info, index) {
            if (info.image2) {
                if (index >= 0) {
                    let typeArr = ['活动', '贷款', '信用卡'],
                        codeArr = [2, 4, 5];
                    this.$sensorsSend('MktClick', {
                        recommend_id: this.$route.query.wxUserId || this.$store.state.vuex_wxUserId || this.wxUserId,
                        $title: typeArr[codeArr.indexOf(info.type)] + '产品详情',
                        mkt_type: '',
                        mkt_name: typeArr[codeArr.indexOf(info.type)] + '产品详情',
                        mkt_location: index + 1,
                        mkt_content_name: info.name,
                        mkt_content_type: typeArr[codeArr.indexOf(info.type)]
                    });
                }
                this.$router.push({
                    path: '/financialShop/picture-detail',
                    query: {
                        wxUserId: this.wxUserId,
                        id: info.id,
                        radar_type_code: info.type == 2 ? '06' : info.type == 4 ? '04' : info.type == 5 ? '05' : '',
                        radar_code: info.id,
                        radar_name: info.name
                    }
                });
            } else {
                this.mxIntoDetail(info);
            }
        },
        mxIntoDetail(info) {
            let { code, name, type } = info,
                typeArr = ['', '', '精选活动', '', '精选贷款', '精选信用卡'],
                clickCodeArr = ['', '', 'JoinActivity', '', 'LoanApplyClick', 'CreditApplyClick'],
                obj = {
                    from_page_name: sessionStorage.getItem('from_page_name') || '',
                    recommend_id: this.$route.query.wxUserId || this.$store.state.vuex_wxUserId || this.wxUserId
                };
            if (type == 4) {
                obj.loan_type = typeArr[Number(type)];
                obj.loan_code = code;
                obj.loan_name = name;
            } else if (type == 5) {
                obj.credit_type = typeArr[Number(type)];
                obj.credit_code = code;
                obj.credit_name = name;
            } else if (type == 2) {
                obj.activity_entrance_type = typeArr[Number(type)];
                obj.activity_type = name;
                obj.activity_name = name;
            }
            this.$sensorsSend(clickCodeArr[Number(type)], obj);
            if (info.loanDescType == 1) {
                // 跳转小程序
                this.$wxApi
                    .launchMiniprogram({
                        appId: info.loanAppId,
                        path: info.loanDescUrl
                    })
                    .then((res) => {
                        //
                    });
            } else if (info.loanDescType == 2) {
                // 跳转外部连接
                if (info.url) {
                    window.location.href = info.url;
                }
            }
        }
    }
};
